# Tanım: Çapraz platform uygulaması ve kullanıcı arayüzü çerçevesi
# URL: http://qt-project.org/
# Paketçi: Cihan_Alkan 
# Gerekler: libjpeg-turbo xcb-util-keysyms xcb-util-renderutil xdg-utils shared-mime-info xcb-util-wm xorg-libxrender xorg-libxi sqlite xcb-util-image icu pcre2 tslib libinput xorg-libsm libxkbcommon libproxy cups double mariadb unixodbc postgresql alsa-lib gstreamer-plugins-base gtk3 pulseaudio freetds
# Grup: geliştirme

isim=qt5-base
surum=5.11.0
devir=1
_pkgfqn="${isim/5-/}-everywhere-src-${surum}"

kaynak=(http://download.qt.io/official_releases/qt/${surum%.*}/${surum}/submodules/${_pkgfqn}.tar.xz
        http://code.qt.io/cgit/qt/qtbase.git/patch/?id=67aa365d::qt-private-includes.patch)

derle() {

  cd ${_pkgfqn}

  # Build qmake using Arch {C,LD}FLAGS
  # This also sets default {C,CXX,LD}FLAGS for projects built using qmake
  sed -i -e "s|^\(QMAKE_CFLAGS_RELEASE.*\)|\1 ${CFLAGS}|" \
    mkspecs/common/gcc-base.conf
  sed -i -e "s|^\(QMAKE_LFLAGS_RELEASE.*\)|\1 ${LDFLAGS}|" \
    mkspecs/common/g++-unix.conf

  # Fix missing private includes https://bugreports.qt.io/browse/QTBUG-37417
  patch -p1 -i ../qt-private-includes.patch

  ./configure -confirm-license -opensource -v \
    -prefix /usr \
    -docdir /usr/share/doc/qt \
    -headerdir /usr/include/qt \
    -archdatadir /usr/lib/qt \
    -datadir /usr/share/qt \
    -sysconfdir /etc/xdg \
    -examplesdir /usr/share/doc/qt/examples \
    -plugin-sql-{psql,mysql,sqlite,odbc} \
    -system-sqlite \
    -openssl-linked \
    -nomake examples \
    -no-rpath \
    -optimized-qmake \
    -dbus-linked \
    -no-use-gold-linker \
    -reduce-relocations
  make
  make INSTALL_ROOT="${PKG}" install

  install -D -m644 LGPL_EXCEPTION.txt \
    "${PKG}"/usr/share/licenses/${isim}/LGPL_EXCEPTION.txt

  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "${PKG}/usr/lib" -type f -name '*.prl' \
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

  # Fix wrong qmake path in pri file
  sed -i "s|${SRC}/${_pkgfqn}|/usr|" \
    "${PKG}"/usr/lib/qt/mkspecs/modules/qt_lib_bootstrap_private.pri

  # Symlinks for backwards compatibility
  for b in "${PKG}"/usr/bin/*; do
    ln -s /usr/bin/$(basename $b) "${PKG}"/usr/bin/$(basename $b)-qt5
  done
}

